var app = require('../app'),
    formMod = require('../../modules/form'),
    ajaxOff = false; 

formMod.listen("/courts/addAndEdit",{
    validError:function(validResutl){
        ajaxOff = false;
        var item  = validResutl.element;
        if(item.attr('name')=='court[court_name]'){
            if(validResutl.valid == 'notempty'){
                toastr.info('请填写法院名称');
            }
        }
        if(item.attr('name')=='court[mobile]'){
            if(validResutl.valid == 'notempty'){
                toastr.info('请填写联系方式');
            }
        }
        if(item.attr('name')=='court[address]'){
            if(validResutl.valid == 'notempty'){
                toastr.info('请填写联系地址');
            }
        }
         
    },
    //操作中清除提示
    cleanup:function(item){
        $('.error-tips').hide().html("");
    },
    success: function(result){
        var res = result.data;
        if(res.code == 200){
            toastr.success('提交成功');
            window.location.href="/courts/index";
        }else{
            toastr.error(res.message);
        }

    },
    error: function(){}
});
$("body")
    .on("change", "#case_source_api", function(){
        if ($(this).prop('checked')) {
            $("#case_get_action").slideDown("fast");
        } else {
            $("#case_get_action").slideUp("fast");
        }
    });

